//
//  GenderViewController.m
//  CoolMove
//
//  Created by CA on 15/4/24.
//  Copyright (c) 2015年 CA. All rights reserved.
//

#import "GenderViewController.h"

@interface GenderViewController () <UIGestureRecognizerDelegate>

@end

@implementation GenderViewController

#pragma mark - View LifeCycle

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self addGestureRecognizer];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
//    [MobClick beginLogPageView:@"GenderPage"];
    
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
//    [MobClick endLogPageView:@"GenderPage"];
}

#pragma mark - IBAction

- (IBAction)chooseGenderMale:(UIButton *)sender
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(genderViewController:didSelectGenderType:)]) {
        [self.delegate genderViewController:self didSelectGenderType:GenderTypeMale];
    }
    [self close];
}

- (IBAction)chooseGenderFemale:(UIButton *)sender
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(genderViewController:didSelectGenderType:)]) {
        [self.delegate genderViewController:self didSelectGenderType:GenderTypeFemale];
    }
    [self close];
}

#pragma mark - Private Method

- (void)addGestureRecognizer
{
    UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(close)];
    gestureRecognizer.cancelsTouchesInView = NO;
    gestureRecognizer.delegate = self;
    [self.view addGestureRecognizer:gestureRecognizer];
}

- (void)close
{
    [self dismissFromParentViewControllerWithAnimationType:DetailViewControllerAnimationTypeSlide];
}

#pragma mark - UIGestureRecognizerDelegate

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    return self.view == touch.view;
}


@end
